--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 8aaa7706368e68de648d61660e16de74106cfbc4
Parents : 3052de5
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-04-12T19:12:24-05:00
refactor(tests): update test selectors
Changes
5 files changed, 26 insertions(+), 31 deletions(-)
Diff
diff --git a/tests/frontend/BotsPage.test.js b/tests/frontend/BotsPage.test.js
index 370cbe4b..2013a0a3 100644
--- a/tests/frontend/BotsPage.test.js
+++ b/tests/frontend/BotsPage.test.js
@@ -62,8 +62,10 @@ describe("BotsPage.vue", () => {
const wrapper = mountBotsPage();
await vi.waitFor(() => expect(wrapper.vm.loading).toBe(false));
- const templateCard = wrapper.find(".glass-card[class*='cursor-pointer']");
- await templateCard.trigger("click");
+ const selectBtn = wrapper
+ .findAll("button")
+ .find((b) => b.text().includes("bots.select"));
+ await selectBtn.trigger("click");
expect(wrapper.vm.selectedTemplate).not.toBeNull();
expect(wrapper.text()).toContain("bots.start_bot: Echo Bot");
diff --git a/tests/frontend/Interface.test.js b/tests/frontend/Interface.test.js
index bf1d2708..3ad56d9b 100644
--- a/tests/frontend/Interface.test.js
+++ b/tests/frontend/Interface.test.js
@@ -37,14 +37,14 @@ describe("Interface.vue", () => {
it("emits disable when Disable button is clicked", async () => {
const wrapper = mountInterface();
- const disableBtn = wrapper.find("button.secondary-chip");
+ const disableBtn = wrapper.find('button[title="interface.disable"]');
await disableBtn.trigger("click");
expect(wrapper.emitted("disable")).toHaveLength(1);
});
it("emits enable when Enable button is clicked for disabled interface", async () => {
const wrapper = mountInterface({ enabled: false });
- const enableBtn = wrapper.find("button.primary-chip");
+ const enableBtn = wrapper.find('button[title="interface.enable"]');
await enableBtn.trigger("click");
expect(wrapper.emitted("enable")).toHaveLength(1);
});
@@ -93,9 +93,11 @@ describe("Interface.vue", () => {
it("action buttons and dropdown have shrink-0 to prevent squashing", () => {
const wrapper = mountInterface();
- const actionsCol = wrapper.find(".flex.flex-col.sm\\:flex-row.gap-2");
+ const actionsCol = wrapper.find(
+ ".absolute.top-2.right-2.z-20.flex.flex-row.items-center.gap-1.sm\\:static",
+ );
expect(actionsCol.classes()).toContain("sm:shrink-0");
- const btn = wrapper.find("button.secondary-chip");
+ const btn = wrapper.find('button[title="interface.disable"]');
expect(btn.classes()).toContain("shrink-0");
});
diff --git a/tests/frontend/ToolsPage.test.js b/tests/frontend/ToolsPage.test.js
index 6567cf87..af51ae5e 100644
--- a/tests/frontend/ToolsPage.test.js
+++ b/tests/frontend/ToolsPage.test.js
@@ -21,6 +21,7 @@ describe("ToolsPage.vue", () => {
{ path: "/paper-message", name: "paper-message", component: { template: "div" } },
{ path: "/rnode-flasher", name: "rnode-flasher", component: { template: "div" } },
{ path: "/debug-logs", name: "debug-logs", component: { template: "div" } },
+ { path: "/mesh-server", name: "mesh-server", component: { template: "div" } },
],
});
@@ -47,11 +48,10 @@ describe("ToolsPage.vue", () => {
expect(wrapper.text()).toContain("tools.power_tools");
});
- it("renders all tool cards", () => {
+ it("renders all tool rows", () => {
const wrapper = mountToolsPage();
- const toolCards = wrapper.findAll(".tool-card");
- // tools count in ToolsPage.vue is 17 (including coming soon ones)
- expect(toolCards.length).toBe(17);
+ const toolRows = wrapper.findAll(".tool-row");
+ expect(toolRows.length).toBe(17);
});
it("filters tools based on search query", async () => {
diff --git a/tests/frontend/UIThemeAndVisibility.test.js b/tests/frontend/UIThemeAndVisibility.test.js
index f6013e27..50a3f474 100644
--- a/tests/frontend/UIThemeAndVisibility.test.js
+++ b/tests/frontend/UIThemeAndVisibility.test.js
@@ -485,7 +485,7 @@ describe("Visibility Checks", () => {
await wrapper.vm.$nextTick();
const colorInputs = wrapper.findAll('input[type="color"]');
- expect(colorInputs.length).toBe(3);
+ expect(colorInputs.length).toBe(2);
delete window.api;
});
diff --git a/tests/frontend/VisualizerOptimization.test.js b/tests/frontend/VisualizerOptimization.test.js
index a24ed267..0a0618fb 100644
--- a/tests/frontend/VisualizerOptimization.test.js
+++ b/tests/frontend/VisualizerOptimization.test.js
@@ -245,7 +245,7 @@ describe("NetworkVisualiser Optimization and Abort", () => {
expect(end - start).toBeLessThan(100); // Should be very fast
});
- it("performance: icon cache hit vs miss for 500 nodes", async () => {
+ it("reuses one cached icon for 500 nodes with identical lxmf_user_icon", async () => {
vi.spyOn(NetworkVisualiser.methods, "init").mockImplementation(() => {});
const wrapper = mountVisualiser();
@@ -266,30 +266,21 @@ describe("NetworkVisualiser Optimization and Abort", () => {
return acc;
}, {});
- // Mock createIconImage to have some delay for the "miss" case
- wrapper.vm.createIconImage = vi.fn().mockImplementation(async () => {
- // Add a tiny delay to ensure "miss" is always measurable
+ wrapper.vm.createIconImage = vi.fn(async function (iconName, foregroundColor, backgroundColor, size = 64) {
+ const cacheKey = `${iconName}-${foregroundColor}-${backgroundColor}-${size}`;
+ if (this.iconCache[cacheKey]) {
+ return this.iconCache[cacheKey];
+ }
await new Promise((r) => setTimeout(r, 0));
- return "blob:mock-icon";
+ const url = "blob:mock-icon";
+ this.iconCache[cacheKey] = url;
+ return url;
});
- const startMiss = performance.now();
await wrapper.vm.processVisualization();
- const endMiss = performance.now();
- const missTime = endMiss - startMiss;
+ expect(wrapper.vm.createIconImage).toHaveBeenCalledTimes(1);
- // Second run will hit the cache check in processVisualization
- // so it won't even call createIconImage.
- const startHit = performance.now();
await wrapper.vm.processVisualization();
- const endHit = performance.now();
- const hitTime = endHit - startHit;
-
- console.log(`Icon cache MISS for 500 nodes: ${missTime.toFixed(2)}ms`);
- console.log(`Icon cache HIT for 500 nodes: ${hitTime.toFixed(2)}ms`);
-
- // Cache hit should be significantly faster, but we allow for some
- // environmental noise in CI environments.
- expect(hitTime).toBeLessThan(missTime + 200);
+ expect(wrapper.vm.createIconImage).toHaveBeenCalledTimes(1);
});
});
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────